import request from '@/utils/request';
import { ApiResult, PageResult } from '@/api';
import { PageFrontSearchParams, PageFront } from '@/api/frontEndAlbum/model';

/**
 * 获取相册内页列表
 * @param data
 */
export async function getPageFrontList(data: PageFrontSearchParams) {
  const res = await request.get<ApiResult<PageResult<PageFront>>>(
    '/albumPage/front',
    {
      params: data
    }
  );
  if (res.data.code === 0) {
    const pageData = {
      list: res.data.data
    };
    return pageData;
  }
  return Promise.reject(new Error(res.data.msg));
}
/**
 *
 * @param url 获取分享的acces_token
 */
export async function getAccesToken(url: string) {
  const res = await request.get<ApiResult<PageResult<PageFront>>>(
    '/wxShare/sign',
    {
      params: url
    }
  );
  if (res.data.code === 0) {
    const pageData = {
      list: res.data.data
    };
    return pageData;
  }
  return Promise.reject(new Error(res.data.msg));
}
